﻿Imports System.Data.SqlClient

Partial Class _Default
    Inherits System.Web.UI.Page

    Dim cn As New SqlConnection(ConfigurationSettings.AppSettings("conn"))
    Dim ids As String
    Dim likes As Integer
    Dim dislikes As Integer
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ids = Request.QueryString("id")
        Label2.Text = Session("username")
        Try

            If (ids >= 1) Then ' we started imageid from 1
                Dim cmd As New SqlCommand("select * from imagetable where imageid=" + ids, cn)
                Dim dr As SqlDataReader
                cn.Open()
                dr = cmd.ExecuteReader
                dr.Read()
                Image1.ImageUrl = dr("imageurl")
                Image1.Height = 500
                Image1.Width = 500
                likes = dr("likes")
                dislikes = dr("dislikes")
                cn.Close()
                cn.Open()
                Dim sql As String = "select Title,Description,UploadDate,UploadBy FROM IMAGETABLE WHERE IMAGEID=" + ids
                Dim sd1 As New SqlDataSource(cn.ConnectionString, sql)
                DetailsView2.DataSource = sd1
                DetailsView2.DataBind()
                cn.Close()
            End If

        Catch ex As Exception

        End Try
        loaddata()


    End Sub

    Public Sub loaddata()

        Chartlet1.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Pie_3D_StarryNight_NoCrystal_NoGlow_NoBorder

        Dim colorguider As ArrayList
        Dim xlabel As New ArrayList
        xlabel.Add("Likes")
        xlabel.Add("Dislikes")
        Dim dataarray() As ArrayList = {New ArrayList}
        dataarray(0).Add(likes)
        dataarray(0).Add(dislikes)

        Chartlet1.ChartTitle.Text = "Popularity Chart"
        Chartlet1.XLabels.UnitText = "Types"
        Chartlet1.YLabels.UnitText = "Maximum %"
        Chartlet1.InitializeData(dataarray, xlabel, colorguider)

    End Sub
End Class
